t = int(input())
while (t):
n, m= map(int, input().split(' '))
mat= list(map(int,input().strip().split()))[:n]
for i in range(n):
mat[i]=mat[i]|m
print(max(mat))
t-=1
#include <bits/stdc++.h>
using namespace std;
#define ar array
#define ll long long
#define ull unsigned long long
#define ld long double
#define sza(x) ((int)x.size())
#define all(a) (a).begin(), (a).end()
#define FOR(i,a,b) for(int (i)=(a);(i)<(b);++(i))
#define REP(i,a) FOR(i,0,a)
ll power(ll a,ll b,ll mod){
ll res=1;
while(b>0){
if(b&1){
res = res*a;
res %= mod;
}
a = a*a;
a %= mod;
b = b>>1;
}
return res;
}
int gcd_array(vector<int> &v){
int gcd=v[0];
// accumulate(v.begin(),v.end(),gcd,gcdFunc);
FOR(i,1,v.size()){
gcd = __gcd(gcd,v[i]);
}
return gcd;
}
const ld pi = 3.141592653589793238;
const int MAX_N = 1e5 + 5;
const ll MOD = 1e9 + 7;
const ll INF = 1e9;
const ld EPS = 1e-9;
void solve(){
ll n,z;
cin>>n>>z;
vector<ll> v(n);
REP(i,n) cin>>v[i];
ll maxi=(v[0]|z);
for(int i=1;i<n;i++){
maxi = max(maxi,(v[i] | z));
}
// cout<<maxi<<endl;
cout<<maxi<<endl;
}
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
freopen("input.txt","r",stdin);
freopen("output.txt","w",stdout);
#endif
int tc=1;
cin >> tc;
for (int t = 1; t <= tc; t++) {
// cout << "Case #" << t << ": ";
solve();
}
}
1288A - Deadline | 1617A - Forbidden Subsequence |
914A - Perfect Squares | 873D - Merge Sort |
1251A - Broken Keyboard | 463B - Caisa and Pylons |
584A - Olesya and Rodion | 799A - Carrot Cakes |
1569B - Chess Tournament | 1047B - Cover Points |
1381B - Unmerge | 1256A - Payment Without Change |
908B - New Year and Buggy Bot | 979A - Pizza Pizza Pizza |
731A - Night at the Museum | 742A - Arpa’s hard exam and Mehrdad’s naive cheat |
1492A - Three swimmers | 1360E - Polygon |
1517D - Explorer Space | 1230B - Ania and Minimizing |
1201A - Important Exam | 676A - Nicholas and Permutation |
431A - Black Square | 474B - Worms |
987B - High School Become Human | 1223A - CME |
1658B - Marin and Anti-coprime Permutation | 14B - Young Photographer |
143A - Help Vasilisa the Wise 2 | 320A - Magic Numbers |